package org.easy.miniooss;


import java.io.InputStream;

/**
 * @author: Li chaojie
 * @Date: 2022/7/5
 * @Description:
 */
public interface OssClientAdapter {

    /**
     * 上传
     *
     * @param ossBaseProperties
     * @param bucket
     * @param ossKey
     * @param inputStream
     * @param objectSize
     * @return
     */
    FileOutDto upload(OssBaseProperties ossBaseProperties, String bucket, String ossKey, InputStream inputStream, Long objectSize);

    FileOutDto upload(OssBaseProperties ossBaseProperties, String bucket, String ossKey, InputStream inputStream, Long objectSize, String endpoint);

    /**
     * 获得公开桶的永久链接
     *
     * @param ossBaseProperties
     * @param bucket
     * @param ossKey
     * @return
     */
    String getPublicUrl(OssBaseProperties ossBaseProperties, String bucket, String ossKey);


    String getPublicUrl(String protocol, String bucket, String ossKey, String endpoint);

    /**
     * 获得预签链接
     *
     * @param ossBaseProperties
     * @param bucket
     * @param ossKey
     * @param expires           过期时间 单位秒  最大7 * 24 * 3600秒
     * @return
     */
    String getPresignedUrl(OssBaseProperties ossBaseProperties, String bucket, String ossKey, Integer expires);

    String getPresignedUrl(OssBaseProperties ossBaseProperties, String endpoint, String bucket, String ossKey, Integer expires);

    /**
     * 对象是否存在
     *
     * @param ossBaseProperties
     * @param bucket
     * @param ossKey
     * @return
     */
    Boolean isExitsObject(OssBaseProperties ossBaseProperties, String bucket, String ossKey);

    /**
     * 文件下载
     *
     * @param ossBaseProperties
     * @param bucket
     * @param ossKey
     * @return 输出流  注意！！ 需要手动关闭
     */
    InputStream downloadFile(OssBaseProperties ossBaseProperties, String bucket, String ossKey);
}
